/*
 * @Description: 编弹表单
 * @Author: HuiSir<https://gitee.com/huisir001>
 * @Date: 2025-08-04 12:04:06
 * @LastEditTime: 2025-08-28 22:37:00
 */
import { defineFormOptions } from "@/components/TablePage/predefined";
import { filePositions } from "./useTableCols";
import { useFormUploadProp } from "@/helpers/optionsMixin";

export default defineFormOptions(() => [
  {
    label: "选择文件",
    component: "upload",
    key: "url",
    props: useFormUploadProp({
      limit: 1,
      allowUrlInsert: false,
      data: {
        fileType: "fileLibrary",
      },
    }),
    inputWidth: 387,
    desc: "允许上传2M的文件",
    rules: {
      required: true,
    },
  },
  {
    label: "存储位置",
    component: "select",
    key: "position",
    default: "local",
    props: {
      placeholder: "请选择存储位置",
    },
    options: Object.keys(filePositions).map((key: string) => ({
      label: (filePositions as Record<string, string>)[key],
      value: key,
    })),
    rules: {
      required: true,
    },
  },
  {
    label: "文件名称",
    component: "input",
    key: "name",
    props: {
      placeholder: "请输入文件名称",
    },
    rules: {
      required: true,
    },
  },
  {
    label: "分组类目",
    component: "select",
    key: "group",
    options: [],
    props: {
      filterable: true,
      allowCreate: true,
      placeholder: "请选择分组类目",
    },
    desc: "可输入新类目",
    rules: {
      required: true,
    },
  },
  {
    label: "文件大小",
    component: "input",
    key: "size",
    props: {
      readonly: true,
      placeholder: "系统获取",
    },
  },
  {
    label: "图片宽度",
    component: "input",
    key: "width",
    props: {
      readonly: true,
      placeholder: "系统获取",
    },
  },
  {
    label: "图片高度",
    component: "input",
    key: "height",
    props: {
      readonly: true,
      placeholder: "系统获取",
    },
  },
  {
    label: "备注",
    component: "input",
    key: "remark",
    props: {
      placeholder: "请输入备注",
      type: "textarea",
    },
  },
]);
